package com.zephyr.vchcenter.bpm.decision;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;

import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.RuleException;
import com.hiaward.bpm.exception.ServiceException;
import com.hiaward.bpm.rule.Decision;
import com.hiaward.framework.taskmanage.service.Service;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.bpm.util.RandomUtil;
import com.zephyr.vchcenter.dao.IVoucherDao;

public class NeedIdentifyVerifyHandler extends Decision {

	private static Logger log = Logger.getLogger(NeedIdentifyVerifyHandler.class);
	
	RandomUtil randomUtil = new RandomUtil();
	ApplicationContext applicationContext = randomUtil.getApplicationContext();
    Service baseService=(Service)applicationContext.getBean("daoService");
	@Override
	public void exceptionHandle(ServiceContext arg0) {

	}

	@Override
	public String make(ServiceContext arg0) throws RuleException,
			ServiceException, ParameterException {
		log.debug("��jin进入NeedIdentifyVerifyHandler------->");
		//String identifyExp = (String) arg0.getInputParameterValue("identifyExp");
		String verifyState = (String) arg0.getInputParameterValue("verifyState");
//		String identifyResult = (String) arg0.getInputParameterValue("identifyResult");
		Voucher voucher = new Voucher();
		String vchsid= (String)arg0.getInputParameterValue("vchsid");
		voucher.setVchsid(vchsid);
		voucher = (Voucher)baseService.getObject(voucher.getClass(), vchsid);
		
		//log.debug(identifyExp +"------------------>");
		/*if(verifyState == null && identifyExp!=null){
			voucher.setIdstate(Integer.parseInt(identifyExp));
			baseService.saveObject(voucher);
			log.debug("ת�����⴦��"+"------------------->");
			return "not to identifyVerify";
		}*/
		
//		voucher.setIdresult(identifyResult);
		
		if ("1".equals(verifyState)) {
			voucher.setIdstate("5");
			baseService.saveObject(voucher);
			return "to identifyVerify";
		}else{
			baseService.saveObject(voucher);
			return "not to identifyVerify";
		}
	}

}
